package zhtt;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * Created by zhtt on 2017/4/10.
 */
public class HbnUtil {
    private static SessionFactory sessionFactory;

    public static Session getSession(){
        if(sessionFactory==null||sessionFactory.isClosed()){
            sessionFactory=new Configuration().configure().buildSessionFactory();
        }
        return sessionFactory.getCurrentSession();
    }
}
